import 'package:flutter/material.dart';
import 'package:fantuike_app/constants.dart' show AppColors, Constants;
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:dio/dio.dart';
import 'package:fantuike_app/api/Api.dart' show Api;
import 'child_page/product_detail.dart';
import 'package:fantuike_app/router/commonRouter.dart';
import 'package:url_launcher/url_launcher.dart';
import 'child_page/store_detail.dart';
import 'child_page/price_detail.dart';
import 'creditcard_list_page.dart';
import 'loan_list_page.dart';
import 'notice_list_page.dart';

class IndexPage extends StatefulWidget {
  @override
  _IndexPageState createState() => _IndexPageState();
}

class _IndexPageState extends State<IndexPage>
    with SingleTickerProviderStateMixin {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        // 搜索组件
        appBar: MyAppBar(
          child: GestureDetector(
            onTap: () {
              print("去产品列表");
            },
            child: Row(
              children: <Widget>[
                Expanded(
                    child: Container(
                  height: 35.0,
                  child: Row(
                    children: <Widget>[
                      Icon(
                        IconData(0xe615, fontFamily: Constants.IconFontFamily),
                        size: 15.0,
                        color: Color(0xffB6B6B6),
                      ),
                      SizedBox(
                        width: 10.0,
                      ),
                      Text(
                        "输入产品名进行搜索",
                        style:
                            TextStyle(color: Color(0xffB6B6B6), fontSize: 13.0),
                      )
                    ],
                  ),
                  margin:
                      const EdgeInsets.only(top: 5.0, left: 15.0, right: 0.0),
                  padding: const EdgeInsets.only(left: 10.0),
                  decoration: BoxDecoration(
                      color: Color(0xffF2F2F2),
                      borderRadius: BorderRadius.all(Radius.circular(18.0))),
                )),
                Stack(
                  overflow: Overflow.visible,
                  alignment: Alignment.center,
                  children: <Widget>[
                    IconButton(
                        icon: Icon(
                          IconData(0xe61d,
                              fontFamily: Constants.IconFontFamily),
                          size: 25.0,
                        ),
                        onPressed: () {
                          Navigator.of(context).push(MaterialPageRoute(
                              builder: (context) => NoticeListPage()));
                        }),
                    Positioned(
                      child: Container(
                        width: 5.0,
                        height: 5.0,
                        alignment: Alignment.bottomCenter,
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(5.0),
                            color: Color(AppColors.NotifyDotBg)),
                      ),
                      right: 13.0,
                      top: 12.0,
                    )
                  ],
                )
              ],
            ),
          ),
        ),
        body: SingleChildScrollView(
          child: Container(
            color: Color(AppColors.AppBackColor),
            child: Column(
              children: <Widget>[
                // 轮播图组件
                buildSwiperWidget(slideImageList),

                // 构建导航组件
                BuildIndexCategoryWidget(),

                // 构建推荐组件
                BuildRecommendWidget(),

                Container(
                  alignment: Alignment.centerLeft,
                  margin:
                      const EdgeInsets.only(top: 5.0, left: 10.0, bottom: 8.0),
                  child: Row(
                    children: <Widget>[
                      Container(
                        width: 4.0,
                        height: 20.0,
                        color: Color(0xfff26966),
                      ),
                      SizedBox(
                        width: 5.0,
                      ),
                      Text("新品速递",
                          style: TextStyle(
                              fontSize: 20.0,
                              fontWeight: FontWeight.w600,
                              color: Color(0xff2C2C2C)))
                    ],
                  ),
                ),

                // 构建新品速递模块
                BuildNewProductWidget(),

                Container(
                  alignment: Alignment.centerLeft,
                  margin: const EdgeInsets.only(
                      top: 10.0, left: 10.0, bottom: 10.0),
                  child: Row(
                    children: <Widget>[
                      Container(
                        width: 4.0,
                        height: 20.0,
                        color: Color(0xfff26966),
                      ),
                      SizedBox(
                        width: 5.0,
                      ),
                      Text("热门商品",
                          style: TextStyle(
                              fontSize: 20.0,
                              fontWeight: FontWeight.w600,
                              color: Color(0xff2C2C2C)))
                    ],
                  ),
                ),
                // 构建热门商品组件
//                BuildHotProductWidget(),

                BuildHotProductWidget(),
                SizedBox(
                  height: 10.0,
                )
              ],
            ),
          ),
        ));
  }

  FocusNode _focusNode = new FocusNode();

  @override
  void initState() {
    super.initState();
    _focusNode.addListener(_focesNodeLister);
    _getHomeInfo();
  }

  @override
  void dispose() {
    _focusNode.removeListener(_focesNodeLister);
    super.dispose();
  }

  Future<Null> _focesNodeLister() async {
    if (_focusNode.hasFocus) {
      print("获得焦点");
    } else {
      print("失去焦点");
    }
  }

  List slideImageList = [];

  void _getHomeInfo() {
    getHomeInfo().then((result) {
//      print(result['extend']['message']['slideImageList']);
      setState(() {
        slideImageList.addAll(result['extend']['message']['slideImageList']);
      });
    });
  }

  Future getHomeInfo() async {
    try {
      Response response = await Dio().get(Api.HomeInfo);
      return response.data;
    } catch (e) {
      print(e);
    }
  }
}

// 首页轮播组件
class buildSwiperWidget extends StatelessWidget {
  List slideImageList;

  buildSwiperWidget(this.slideImageList);

  List _swiperList = [
    NetworkImage("https://fantuike.com/3618e4802ac5406098ef7c5cb0a916d2.png"),
    NetworkImage("https://fantuike.com/32b9b9e8b7914975ab985324a7fec8f1.png"),
    NetworkImage("https://fantuike.com/d16db5fedbc74cfba811b6ffe1967ded.png"),
    NetworkImage("https://fantuike.com/85be2ecdfa3e4911b78fcf71d1ec7c2d.png"),
    NetworkImage("https://fantuike.com/508291b357a942cfbfbd7e3e00588333.png"),
  ];

  @override
  Widget build(BuildContext context) {
    ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
    return Container(
      alignment: Alignment.center,
      height: ScreenUtil().setHeight(300),
      width: ScreenUtil().setWidth(750),
      margin: const EdgeInsets.only(top: 10.0, bottom: 15.0),
      child: Swiper(
        duration: 500,
        controller: new SwiperController(),
        viewportFraction: 0.80,
        scale: 0.9,
        autoplay: true,
        itemCount: _swiperList.length,
        itemBuilder: (BuildContext context, int index) {
          return Container(
            decoration: BoxDecoration(
                image: DecorationImage(
                    image: _swiperList[index], fit: BoxFit.fill),
                borderRadius: BorderRadius.all(Radius.circular(13.0))),
          );
        },
      ),
      decoration:
          BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(10.0))),
    );
  }
}

// 构建首页商品类目导航
class BuildIndexCategoryWidget extends StatelessWidget {
  final List<Text> _noticeList = [
    Text(
      "我们上线啦！四大活动伴你行走江湖!",
      maxLines: 1,
      overflow: TextOverflow.ellipsis,
    ),
    Text(
      "我们上线啦！四大活动伴你行走江湖!",
      maxLines: 1,
      overflow: TextOverflow.ellipsis,
    ),
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 110.0,
      margin: const EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0),
      alignment: Alignment.centerLeft,
      decoration: BoxDecoration(
          color: Color(AppColors.AppBackColor),
          borderRadius: BorderRadius.all(
            Radius.circular(12.0),
          ),
          boxShadow: <BoxShadow>[
            BoxShadow(blurRadius: 2.5, color: Color(0xffC5C5C5)),
          ]),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          Container(
            padding: const EdgeInsets.only(left: 15.0),
            height: 30.0,
            // alignment: Alignment.center,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Icon(
                  IconData(0xe61b, fontFamily: Constants.IconFontFamily),
                  color: Color(AppColors.noticeColor),
                  size: 18.0,
                ),
                Expanded(
                    child: Container(
                  margin: const EdgeInsets.only(top: 5.0, left: 10.0),
                  alignment: Alignment.center,
                  child: Swiper(
                    autoplay: true,
                    duration: 500,
                    scrollDirection: Axis.vertical,
                    itemCount: _noticeList.length,
                    itemBuilder: (BuildContext context, int index) {
                      return _noticeList[index];
                    },
                  ),
                ))
              ],
            ),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(width: 1.0, color: Color(0xffEEEEEE)))),
          ),
          Container(
            alignment: Alignment.center,
            height: 80.0,
//            padding: const EdgeInsets.only(bottom: 5.0),
            child: Row(
              children: <Widget>[
                Expanded(
                    child: GestureDetector(
                  onTap: () {
                    Navigator.of(context).push(MaterialPageRoute(
                        builder: (BuildContext context) =>
                            new CreditCardListPage()));
//                    Navigator.of(context)
//                        .push(CommonRouter(CreditCardListPage()));
                  },
                  child: Container(
                      child: Container(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Container(
                          padding: const EdgeInsets.all(7.0),
                          child: Icon(
                            IconData(0xe6a7,
                                fontFamily: Constants.IconFontFamily),
                            color: Color(0xffffffff),
                            size: 25.0,
                          ),
                          decoration: BoxDecoration(
                              border: Border.all(color: Color(0xff7565D0)),
                              color: Color(0xff7565D0),
                              borderRadius:
                                  BorderRadius.all(Radius.circular(25.0))),
                        ),
                        SizedBox(
                          height: 5.0,
                        ),
                        Text(
                          "信用卡",
                          style: TextStyle(fontSize: 13.0),
                        )
                      ],
                    ),
                  )),
                )),
                Expanded(
                    child: GestureDetector(
                  onTap: () {
                    Navigator.of(context).push(CommonRouter(LoanListPage()));
                  },
                  child: Container(
                      child: Container(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Container(
                          padding: const EdgeInsets.all(7.0),
                          child: Icon(
                            IconData(0xe63e,
                                fontFamily: Constants.IconFontFamily),
                            color: Color(0xffffffff),
                            size: 25.0,
                          ),
                          decoration: BoxDecoration(
                              border: Border.all(color: Color(0xffED4E3E)),
                              color: Color(0xffED4E3E),
                              borderRadius:
                                  BorderRadius.all(Radius.circular(25.0))),
                        ),
                        SizedBox(
                          height: 5.0,
                        ),
                        Text("贷款", style: TextStyle(fontSize: 13.0))
                      ],
                    ),
                  )),
                )),
                Expanded(
                    child: GestureDetector(
                  onTap: () {
                    Navigator.of(context).push(CommonRouter(StoreDetailPage()));
                  },
                  child: Container(
                      child: Container(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Container(
                          padding: const EdgeInsets.all(7.0),
                          child: Icon(
                            IconData(0xe655,
                                fontFamily: Constants.IconFontFamily),
                            color: Color(0xffffffff),
                            size: 25.0,
                          ),
                          decoration: BoxDecoration(
                              border: Border.all(color: Color(0xffF34D75)),
                              color: Color(0xffF34D75),
                              borderRadius:
                                  BorderRadius.all(Radius.circular(25.0))),
                        ),
                        SizedBox(
                          height: 5.0,
                        ),
                        Text("我的店铺", style: TextStyle(fontSize: 13.0))
                      ],
                    ),
                  )),
                )),
                Expanded(
                    child: GestureDetector(
                  child: Container(
                      child: Container(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Container(
                          padding: const EdgeInsets.all(7.0),
                          child: Icon(
                            IconData(0xe796,
                                fontFamily: Constants.IconFontFamily),
                            color: Color(0xffffffff),
                            size: 25.0,
                          ),
                          decoration: BoxDecoration(
                              border: Border.all(color: Color(0xffFD7507)),
                              color: Color(0xffFD7507),
                              borderRadius:
                                  BorderRadius.all(Radius.circular(25.0))),
                        ),
                        SizedBox(
                          height: 5.0,
                        ),
                        Text("价格表", style: TextStyle(fontSize: 13.0))
                      ],
                    ),
                  )),
                  onTap: () {
                    Navigator.of(context).push(CommonRouter(PriceDetailPage()));
                  },
                )),
              ],
            ),
          )
        ],
      ),
    );
  }
}

// 构建开通会员组件
class BuildMemberWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(left: 10.0, right: 10.0, top: 10.0),
      padding: const EdgeInsets.only(left: 15.0, right: 10.0),
      alignment: Alignment.centerLeft,
      height: 45.0,
      decoration: BoxDecoration(
          color: Color(AppColors.memberBtnColor),
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(10.0), topRight: Radius.circular(10.0))),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Container(
            child: Row(
              children: <Widget>[
                Icon(
                  IconData(0xe625, fontFamily: Constants.IconFontFamily),
                  color: Color(AppColors.memberFontColor),
                ),
                SizedBox(
                  width: 3.0,
                ),
                Text(
                  "泛推客会员",
                  style: TextStyle(
                      color: Color(AppColors.memberFontColor), fontSize: 16.0),
                ),
              ],
            ),
          ),
          Container(
            padding: const EdgeInsets.only(left: 5.0, top: 2.0, bottom: 2.0),
            child: Row(
              children: <Widget>[
                Text("开通"),
                Icon(
                  IconData(0xe604, fontFamily: Constants.IconFontFamily),
                  size: 14.0,
                )
              ],
            ),
            decoration: BoxDecoration(
                color: Color(0xffFEF3C6),
                borderRadius: BorderRadius.all(Radius.circular(10.0))),
          )
        ],
      ),
    );
  }
}

// 构建新品速递模块
class BuildNewProductWidget extends StatefulWidget {
  @override
  _BuildNewProductWidgetState createState() => _BuildNewProductWidgetState();
}

class _BuildNewProductWidgetState extends State<BuildNewProductWidget> {
  List newProductList = [];

  @override
  void initState() {
    super.initState();
    getNewProductList();
  }

  void getNewProductList() {
    _getNewProductList().then((data) {
      setState(() {
        newProductList.addAll(data['extend']['message']['newProductList']);
      });
    });
  }

  Future _getNewProductList() async {
    try {
      Response response = await Dio().get(Api.HomeInfo);
      return response.data;
    } catch (e) {}
  }

  @override
  Widget build(BuildContext context) {
    return Container(
        height: 180.0,
        child: ListView.builder(
          scrollDirection: Axis.horizontal,
          itemCount: newProductList.length,
          itemBuilder: (BuildContext context, int index) {
            return GestureDetector(
                onTap: () {
                  int productType = newProductList[index]['productType'];
                  int productId = newProductList[index]['id'];
                  if (productType == 0) {
                    // 信用卡
                    Navigator.of(context).push(CommonRouter(ProductDetailPage(
                        productId: productId, productType: productType)));
                  } else {
                    // 贷款
                    Navigator.of(context).push(CommonRouter(ProductDetailPage(
                        productId: productId, productType: productType)));
                  }
                },
                child: new Container(
                  margin: const EdgeInsets.only(left: 10.0, right: 10.0),
                  width: 175.0,
                  child: Column(
                    children: <Widget>[
                      ClipRRect(
                        borderRadius: BorderRadius.only(
                            topLeft: Radius.circular(8.0),
                            topRight: Radius.circular(8.0)),
                        child: Image.network(
                            newProductList[index]['firstPicture']),
                      ),
                      Container(
                        alignment: Alignment.center,
                        margin: const EdgeInsets.only(
                            left: 3.0, right: 3.0, top: 2.0),
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: <Widget>[
                            Text(newProductList[index]['name'],
                                style: TextStyle(
                                    color: Color(0xff323232), fontSize: 15.0)),
                            Container(
                              margin: const EdgeInsets.only(top: 2.0),
                              padding: const EdgeInsets.only(
                                  left: 1.0, right: 1.0, top: 1.0, bottom: 1.0),
                              alignment: Alignment.center,
                              child: Text(
                                "每周五结",
                                style: TextStyle(
                                    color: Color(0xffFFAE51), fontSize: 10.0),
                              ),
                              decoration: BoxDecoration(
                                  border: Border.all(
                                      width: 1.0, color: Color(0xffFFAE51)),
                                  borderRadius:
                                      BorderRadius.all(Radius.circular(3.0))),
                            )
                          ],
                        ),
                      ),
                      Container(
                        margin: const EdgeInsets.only(left: 3.0, top: 3.0),
                        alignment: Alignment.centerLeft,
                        child: Text(
                          "通过率: " + newProductList[index]['passRate'],
                          style: TextStyle(
                              color: Color(0xff969696), fontSize: 11.0),
                        ),
                      ),
                      Container(
                        margin: const EdgeInsets.only(left: 3.0),
                        alignment: Alignment.centerLeft,
                        child: Text(
                          "已发放奖金: " + newProductList[index]['haveBonus'] + "元",
                          style: TextStyle(
                              color: Color(0xff969696), fontSize: 11.0),
                        ),
                      ),
                      Container(
                        margin: const EdgeInsets.only(top: 5.0, bottom: 4.0),
                        padding: const EdgeInsets.only(top: 2.0, bottom: 2.0),
                        width: 130.0,
                        alignment: Alignment.center,
                        child: Text(
                          newProductList[index]['moneyDescription'],
                          style: TextStyle(
                              color: Color(0xffffffff), fontSize: 12.0),
                        ),
                        decoration: BoxDecoration(
                            color: Color(0xffF26966),
                            borderRadius:
                                BorderRadius.all(Radius.circular(10.0))),
                      )
                    ],
                  ),
                  decoration: BoxDecoration(
                      border: Border.all(width: 1.0, color: Color(0xffF5F5F5)),
                      // color: Colors.lightBlue,
                      borderRadius: BorderRadius.all(Radius.circular(9.0))),
                ));
          },
        ));
  }
}

// 构建推荐组件
class BuildRecommendWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
//        print("推荐组件");
        const url = "https://www.baidu.com";
        launch(url);
      },
      child: Container(
        margin: const EdgeInsets.only(left: 5.0, right: 5.0),
        alignment: Alignment.center,
        height: 80.0,
        child: Image.asset(
          "assets/images/RecommendImg.png",
          fit: BoxFit.fill,
        ),
      ),
    );
  }
}

// 构建热门商品组件
class BuildHotProductWidget extends StatefulWidget {
  @override
  _BuildHotProductWidgetState createState() => _BuildHotProductWidgetState();
}

class _BuildHotProductWidgetState extends State<BuildHotProductWidget> {
  List newProductList = [];

  @override
  void initState() {
    super.initState();
    getNewProductList();
  }

  void getNewProductList() {
    _getNewProductList().then((data) {
      setState(() {
        newProductList.addAll(data['extend']['message']['hotProductList']);
      });
    });
  }

  Future _getNewProductList() async {
    try {
      Response response = await Dio().get(Api.HomeInfo);
      return response.data;
    } catch (e) {}
  }

  @override
  Widget build(BuildContext context) {
    List<Widget> tiles = [];

    for (var item in newProductList) {
      tiles.add(GestureDetector(
          onTap: () {
            int productType = item['productType'];
            int productId = item['id'];
            if (productType == 0) {
              // 信用卡
              Navigator.of(context).push(CommonRouter(ProductDetailPage(
                  productId: productId, productType: productType)));
            } else {
              // 贷款
              Navigator.of(context).push(CommonRouter(ProductDetailPage(
                  productId: productId, productType: productType)));
            }
          },
          child: new Container(
            margin: const EdgeInsets.only(left: 10.0, right: 10.0),
            width: 175.0,
            child: Column(
              children: <Widget>[
                ClipRRect(
                  borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(8.0),
                      topRight: Radius.circular(8.0)),
                  child: Image.network(
                    item['firstPicture'],
                    fit: BoxFit.fill,
                  ),
                ),
                Container(
                  alignment: Alignment.center,
                  margin:
                      const EdgeInsets.only(left: 3.0, right: 3.0, top: 2.0),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      Text(item['name'],
                          style: TextStyle(
                              color: Color(0xff323232), fontSize: 15.0)),
                      Container(
                        margin: const EdgeInsets.only(top: 2.0),
                        padding: const EdgeInsets.only(
                            left: 1.0, right: 1.0, top: 1.0, bottom: 1.0),
                        alignment: Alignment.center,
                        child: Text(
                          "每周五结",
                          style: TextStyle(
                              color: Color(0xffFFAE51), fontSize: 10.0),
                        ),
                        decoration: BoxDecoration(
                            border: Border.all(
                                width: 1.0, color: Color(0xffFFAE51)),
                            borderRadius:
                                BorderRadius.all(Radius.circular(3.0))),
                      )
                    ],
                  ),
                ),
                Container(
                  margin: const EdgeInsets.only(left: 3.0, top: 3.0),
                  alignment: Alignment.centerLeft,
                  child: Text(
                    "通过率: " + item['passRate'],
                    style: TextStyle(color: Color(0xff969696), fontSize: 11.0),
                  ),
                ),
                Container(
                  margin: const EdgeInsets.only(left: 3.0),
                  alignment: Alignment.centerLeft,
                  child: Text(
                    "已发放奖金: " + item['haveBonus'] + "元",
                    style: TextStyle(color: Color(0xff969696), fontSize: 11.0),
                  ),
                ),
                Container(
                  margin: const EdgeInsets.only(top: 5.0, bottom: 4.0),
                  padding: const EdgeInsets.only(top: 2.0, bottom: 2.0),
                  width: 130.0,
                  alignment: Alignment.center,
                  child: Text(
                    item['moneyDescription'],
                    style: TextStyle(color: Color(0xffffffff), fontSize: 12.0),
                  ),
                  decoration: BoxDecoration(
                      color: Color(0xffF26966),
                      borderRadius: BorderRadius.all(Radius.circular(10.0))),
                )
              ],
            ),
            decoration: BoxDecoration(
                border: Border.all(width: 1.0, color: Color(0xffF5F5F5)),
                // color: Colors.lightBlue,
                borderRadius: BorderRadius.all(Radius.circular(9.0))),
          )));
    }

    return ListView(
      physics: NeverScrollableScrollPhysics(),
      scrollDirection: Axis.vertical,
      shrinkWrap: true,
      padding: const EdgeInsets.all(0.0),
      children: <Widget>[
        GridView.count(
            childAspectRatio: 1 / 1,
            mainAxisSpacing: 10.0,
            crossAxisSpacing: 0.0,
            padding: const EdgeInsets.only(
                top: 0.0, bottom: 5.0, left: 5.0, right: 5.0),
            physics: NeverScrollableScrollPhysics(),
            shrinkWrap: true,
            crossAxisCount: 2,
            children: tiles)
      ],
    );
  }
}

// 构建自定义AppBar
class MyAppBar extends StatefulWidget implements PreferredSizeWidget {
  final Widget child;

  MyAppBar({@required this.child}) : assert(child != null);

  @override
  _MyAppBarState createState() => _MyAppBarState();

  @override
  Size get preferredSize => new Size.fromHeight(45.0);
}

class _MyAppBarState extends State<MyAppBar> {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: widget.child,
      top: true,
    );
  }
}
